/**
 *
 */
package jp.seraph.same.model;

import java.util.ArrayList;
import java.util.List;

import jp.seraph.jsmf.codec.PoseNameLinkMotionElement;
import jp.seraph.jsmf.motion.DefaultMotionSession;
import jp.seraph.jsmf.motion.MotionElement;
import jp.seraph.jsmf.motion.MotionSession;

/**
 *
 */
public class DefaultMotionSessionModel extends AbstractMapHierarchicalViewModel<MotionElementModel> implements MotionSessionModel {
    public DefaultMotionSessionModel(String aName) {
        super(aName);
    }

    public DefaultMotionSessionModel(MotionSession aSession){
        this(aSession.getName());

        for (MotionElement tElement : aSession.toElementList()) {
            this.add(new DefaultMotionElementModel((PoseNameLinkMotionElement)tElement));
        }
    }

    /**
     *
     * @see jp.seraph.same.model.MotionSessionModel#toElementList()
     */
    public List<MotionElementModel> toElementList() {
        return new ArrayList<MotionElementModel>(getChildMap().values());
    }

    public MotionSession toSession() {
        DefaultMotionSession tSession = new DefaultMotionSession(this.getName());
        for (MotionElementModel tElement : this) {
            tSession.addElement(tElement.toElement());
        }

        return tSession;
    }
}
